import 'dart:async';
import 'package:bloc/bloc.dart';
import './bloc.dart';

class IpsettingBloc extends Bloc<IpsettingEvent, IpsettingState> {
  @override
  IpsettingState get initialState => InitialIpsettingState();

  @override
  Stream<IpsettingState> mapEventToState(
    IpsettingEvent event,
  ) async* {
      if (event is IpSettingSaveEvent) {
       bool result = await event.saveSetting();
       yield  IpSettingSaveEventState(result,event.ipError,event.portError);
      }

      if ( event is IpSettingGetEvent) {
        yield IpSettingGetEventState(event.getLocalSetting());
      }

      if (event is NullEvent) {
        yield NullState();
      }
  }
}
